﻿namespace Mekiasm
{
    public class Battery : ItemFlat, Interface.IChargeAbleItem
    {
        public static int Index;

        public long MaxAmount => GetMaxPower();

        public ComponentEnergyMachine.FuelType ChargeFuelType => ComponentEnergyMachine.FuelType.Electric;

        public Battery() : base("充电电池", MekiasmInit.GetFlatTexture(MekiasmInit.R1, "battery"))
        {
        }

        public override int GetMaxPower()
        {
            return 10240;
        }

        public override float GetBlockHealth(int value)
        {
            SaveItemSystem.GetBlockData(value, out var d);
            if (d == null) return -1f;
            else return GetCurrentAmount(value) / (float)GetMaxPower();
        }

        public long GetCurrentAmount(int value)
        {
            SaveItemSystem.GetBlockData(value,out var d);
            if (d == null) return 0;
            else return d.fuelAmount;
        }

        public int SetCurrentAmount(int value, int fuelValue, long varAmount)
        {
            return SaveItemSystem.ChangePower(value, varAmount, fuelValue);
        }


        public int GetChargeFuelValue(int value)
        {
            return 0;
        }

        public bool CanAcceptFuel(int value)
        {
            return true;
        }
    }
}
